/*功能样例*/

// #include "util.hpp"
// #include "level.hpp"
// #include "message.hpp"
// #include "format.hpp"
// #include "sink.hpp"
// #include "logger.hpp"
// #include "buffer.hpp"
#include "../logs/bitlog.h"
#include <unistd.h>

void test_log(const std::string &name)
{
    INFO("%s", "测试开始");
    bitlog::Logger::ptr logger = bitlog::LoggerManager::getInstance().getLogger(name);
    logger->debug("%s", "测试日志");
    logger->info("%s", "测试日志");
    logger->warn("%s", "测试日志");
    logger->error("%s", "测试日志");
    logger->fatal("%s", "测试日志");

    INFO("%s", "测试完毕");

}

int main()
{
    // 测试
    std::unique_ptr<bitlog::LoggerBuilder> builder(new bitlog::GlobalLoggerBuilder()); // 全局日志器的建造者
    builder->buildLoggerName("async_logger");
    builder->buildLoggerLevel(bitlog::LogLevel::value::DEBUG);
    builder->buildFormatter("[%c][%f:%l][%p]%m%n");
    builder->buildLoggerType(bitlog::LoggerType::LOGGER_SYNC);
    builder->buildSink<bitlog::FileSink>("./logfile/async.log");
    builder->buildSink<bitlog::StdoutSink>();
    builder->buildSink<bitlog::RollBySizeSink>("./logfile/roll-async-by-size",1024*1024);
    builder->build();
    test_log("async_logger");
    return 0;
}